package com.weixin.paleituo.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.weixin.paleituo.R;

/**
 * Author yichao
 * Time  2017/12/11 15:44
 * Dest  登录itemView自定义
 */

public class LoginItemView extends LinearLayout {

    private LinearLayout mLinearLayout;
    private TextView mTvName,mTvGetMessage;
private EditText mEtContent;
    private ImageView mIvEye;


    public LoginItemView(Context context) {
        this(context, null);
    }

    public LoginItemView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
        mLinearLayout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.item_login_layout, this, true);
        mTvName = mLinearLayout.findViewById(R.id.tv_nane_item_login_layout);
        mEtContent = mLinearLayout.findViewById(R.id.et_content_item_login_layout);
        mIvEye = mLinearLayout.findViewById(R.id.iv_eye_item_login_layout);
        mTvGetMessage=mLinearLayout.findViewById(R.id.tv_getmessage_item_login_layout);
        TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.LoginItemView);

        String name = attributes.getString(R.styleable.LoginItemView_login_name);
        if (name != null && !name.equals("")) {
            mTvName.setText(name);
        }
        String detais = attributes.getString(R.styleable.LoginItemView_login_content);
        if (detais != null && !detais.equals("")) {
            mEtContent.setHint(detais);
        }
        boolean showEye = attributes.getBoolean(R.styleable.LoginItemView_login_show_eye, false);
        if (showEye){
            mIvEye.setVisibility(VISIBLE);
        }
        boolean showCheckCode = attributes.getBoolean(R.styleable.LoginItemView_login_show_check_code, false);
        if (showCheckCode){
            mTvGetMessage.setVisibility(VISIBLE);
        }


        attributes.recycle();





    }

    public LoginItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

    }

    public EditText getEditText(){
        return mEtContent;
    }

    public ImageView getImagView(){
        return mIvEye;
    }
    public TextView getMessageTextView(){
        return mTvGetMessage;
    }
}
